package;

import js.Browser.*;
import lib.THREE;
import lib.THREE.*;

class Main {
	static public function main() {
		var scene = new Scene();
		var camera = new PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
		var render = new WebGLRenderer();
		render.setSize(window.innerWidth, window.innerHeight);
		render.setPixelRatio(window.devicePixelRatio);
		var texture = new TextureLoader().load('https://threejs.org/examples/textures/crate.gif');
		var box = new Mesh(new BoxBufferGeometry(2, 2, 2), new MeshBasicMaterial({map: texture})); 
		box.position.set(0, 0, 0);
		scene.add(box);
		camera.position.set(5, 5, 5);
		camera.lookAt(box.position);
		document.body.appendChild(render.domElement);
		var _render = null;
		function _render(?f:Float):Void {
			window.requestAnimationFrame(_render);
			box.rotation.x += 0.1;
			box.rotation.y += 0.1;
			render.render(scene, camera);
		}
		_render();
	}
}
